#ifndef __MEDIA_H
#define __MEDIA_H

#include "protocol.h"
#include <pthread.h>

typedef struct cmd_base cmd_base_t;
struct cmd_base  {
    bool run;
    bool repeat;
    char cmd[CMD_LEN];
    pthread_t tid;
    pthread_mutex_t mutex;
    pid_t pid;
    int (*exec)(cmd_base_t *cmd_base);
};

typedef struct rtsp_to_rtmp {
    cmd_base_t cmd_base;
    char rtsp_url[URL_LEN];
    char rtmp_url[URL_LEN];
    char recode[RESOLUTION_LEN];
}rtsp_to_rtmp_t;

typedef struct rtsp_screenshot {
    cmd_base_t cmd_base;
    char rtsp_url[URL_LEN ];
    char out_path[OUT_PATH_LEN];
}rtsp_screenshot_t;

typedef struct rtsp_record {
    cmd_base_t cmd_base;
    char rtsp_url[URL_LEN];
    char out_path[OUT_PATH_LEN];
} rtsp_record_t;

typedef struct user_cmd {
    cmd_base_t cmd_base;
    char cmd[CMD_LEN];
}user_cmd_t ;

typedef struct media_ffmpeg {
    media_t media;
    rtsp_to_rtmp_t rtsp_to_rtmp;
    rtsp_record_t rtsp_record;
    rtsp_screenshot_t rtsp_screenshot;
    user_cmd_t user_cmd;
} media_ffmpeg_t;

media_t* media_ffmpeg_new();

void media_ffmpeg_delete(media_t *med);

#endif // !__MEDIA_H
